package com.sojson.config.listener;

import java.util.EventListener;

import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.util.IntrospectorCleanupListener;

import lombok.extern.slf4j.Slf4j;

/**
 * 配置监听器bean
 * 
 * @author liu
 * @date 2020-11-02
 */
@Slf4j
@Configuration
public class ListenerConfig {

    /**
     * 配置防止spring内存溢出监听器(不知道干嘛的,看名字感觉加上好)
     * 
     * @return
     */
    @Bean
    public ServletListenerRegistrationBean<EventListener> introspectorCleanupListener() {
        ServletListenerRegistrationBean<EventListener> servletListenerRegistrationBean =
            new ServletListenerRegistrationBean<>(new IntrospectorCleanupListener());
        log.info("防止spring内存溢出监听器注入成功！");
        return servletListenerRegistrationBean;
    }

}